package com.hotpot.api.api.core;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * 描述：
 *
 * @author: ruikanwang
 * @date: 2018/1/19 0019 13:20
 * @version: V1.0
 * 注意：本内容仅限于新疆感知科技有限公司内部传阅,禁止外泄以及用于其他的商业目
 * Copyright © 2018-ganinfo. All rights reserved.
 */
@RestController
public class ApiController {

    @Autowired
    private ApiGatewayHand apiHand;

    /**
     * 所有post请求
     * @return
     */
    @PostMapping("/api")
    public Object apiPost(String method,String params){
        return  apiHand.handle(getRequest());
    }

    /**
     *所有get请求
     * @return
     */
    @GetMapping("/api")
    public Object apiGet(){
        return  apiHand.handle(getRequest());
    }

    public HttpServletRequest getRequest() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        return request;
    }




}
